Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

test: add comprehensive tests for resolve-target module - #199

Merged
BYK merged 2 commits into
mainfrom
byk/test-resolve-target
Feb 5, 2026
Merged

BYK merged 2 commits into
mainfrom
byk/test-resolve-target

Conversation

@BYK

@BYK BYK commented Feb 5, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add comprehensive tests for the resolve-target module with proper test isolation
  • Coverage improved from 15.28% to 72.49% for resolve-target.ts

Changes

Test Structure

Due to Bun's mock.module() affecting global module state, tests are organized into:

  1. test/lib/resolve-target.test.ts - Pure function property tests (no mocks)

    • isValidDirNameForInference property and edge case tests (7 tests)
  2. test/isolated/resolve-target.test.ts - Integration tests with mocked dependencies (27 tests)

    • Run with bun run test:isolated to avoid interfering with other tests

Functions Tested

Function Tests Description
isValidDirNameForInference 7 Property tests + edge cases
resolveOrg 7 CLI flags, defaults, DSN detection, error handling
resolveFromDsn 6 Cache hits, API fetches, fallback behavior
resolveOrgAndProject 7 Flag validation, defaults, DSN, directory inference
resolveAllTargets 7 Monorepo multi-DSN, deduplication, empty results

Package.json

Added new test script:

"test:isolated": "bun test test/isolated"

Running Tests

# Run unit tests (excludes isolated tests)
bun run test:unit

# Run isolated tests (tests with module mocks)
bun run test:isolated

# Run all tests
bun test

Add unit tests for org/project resolution functions:
- resolveOrg: CLI flags, defaults, DSN detection fallback
- resolveFromDsn: cache hits, API fetches, missing orgId/projectId
- resolveOrgAndProject: flag validation, defaults, DSN, directory inference
- resolveAllTargets: monorepo multi-DSN, deduplication, error propagation

Coverage improved from 15.28% to 95.65% (366 → ~30 uncovered lines).
@github-actions

github-actions Bot commented Feb 5, 2026 •

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

⚪ None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Dsn

  • Infer project from directory name when DSN detection fails by BYK in #178
  • Add project root detection for automatic DSN discovery by BYK in #159

Other

  • (commands) Add sentry log command by betegon in #160
  • (issue) Replace --org/--project flags with /ID syntax by BYK in #161
  • (lib) Add anyTrue helper for parallel-with-early-exit pattern by BYK in #174
  • (telemetry) Add withTracing helper to reduce Sentry span boilerplate by BYK in #172

Bug Fixes 🐛

  • (types) Align schema types with Sentry API by betegon in #169
  • Improved the plan command by MathurAditya724 in #185
  • Use ASCII arrow for consistent terminal rendering by BYK in #192
  • Corrected the rendering and props for the span tree by MathurAditya724 in #184
  • ParseIssueArg now checks slashes before dashes by BYK in #177
  • Address bugbot review comments on dsn-cache model-based tests by BYK in #176
  • Added nullable in substatus's zod validation by MathurAditya724 in #157

Documentation 📚

  • Update AGENTS.md with testing guidelines and architecture by BYK in #190

Internal Changes 🔧

  • (upgrade) Use centralized user-agent for GitHub API requests by BYK in #173

Other

  • test: add comprehensive tests for resolve-target module by BYK in #199
  • test: add tests for executeUpgrade with unknown method by BYK in #198
  • test: expand version check test coverage by BYK in #196
  • test: add comprehensive tests for DSN errors and resolver by BYK in #195
  • test: add comprehensive tests for human formatter detail functions by BYK in #194
  • test: add comprehensive tests for human formatter utilities by BYK in #191
  • test: add coverage for fetchLatestVersion and versionExists by BYK in #189
  • test: add coverage for UpgradeError and SeerError classes by BYK in #188
  • test: add property tests for sentry-urls.ts (Phase 3) by BYK in #186
  • test: simplify issue-id tests covered by property tests by BYK in #183
  • test: simplify alias and arg-parsing tests covered by property tests by BYK in #182
  • test: add property tests for API command and human formatters by BYK in #181
  • test: remove redundant DB tests covered by model-based tests by BYK in #180
  • test: add property tests for async utilities (Phase 4) by BYK in #179
  • test: add model-based tests for DSN and project cache by BYK in #171
  • test: add model-based and property-based testing with fast-check by BYK in #166

🤖 This preview updates automatically when you update the PR.

- Move integration tests with mock.module() to test/isolated/ directory
  to run separately from unit tests (Bun mocks affect global module state)
- Keep pure function property tests in test/lib/resolve-target.test.ts
- Add test:isolated script for running isolated tests
- Coverage improved from 15.28% to 72.49% for resolve-target.ts

The isolated tests cover:
- resolveOrg: CLI flags, defaults, DSN detection, error handling
- resolveFromDsn: cache hits, API fetches, fallback behavior
- resolveOrgAndProject: flag validation, defaults, DSN, directory inference
- resolveAllTargets: monorepo multi-DSN, deduplication, empty results
@github-actions

github-actions Bot commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 1709 uncovered lines.
❌ Project coverage is 77.2%. Comparing base (base) to head (head).

Files with missing lines (32)
File Patch % Lines
human.ts 53.59% ⚠️ 388 Missing
resolve-target.ts 15.28% ⚠️ 366 Missing
oauth.ts 25.10% ⚠️ 194 Missing
api-client.ts 70.62% ⚠️ 176 Missing
upgrade.ts 45.49% ⚠️ 139 Missing
migration.ts 47.44% ⚠️ 82 Missing
api.ts 89.80% ⚠️ 47 Missing
telemetry.ts 79.91% ⚠️ 45 Missing
seer.ts 75.54% ⚠️ 45 Missing
seer.ts 79.87% ⚠️ 30 Missing
preload.ts 53.23% ⚠️ 29 Missing
schema.ts 52.73% ⚠️ 26 Missing
utils.ts 88.94% ⚠️ 25 Missing
detector.ts 90.10% ⚠️ 20 Missing
code-scanner.ts 95.00% ⚠️ 16 Missing
arg-parsing.ts 90.00% ⚠️ 12 Missing
dsn-cache.ts 94.62% ⚠️ 12 Missing
fs-utils.ts 57.14% ⚠️ 9 Missing
project-root.ts 97.73% ⚠️ 7 Missing
version-check.ts 91.14% ⚠️ 7 Missing
feedback.ts 84.21% ⚠️ 6 Missing
auth.ts 95.52% ⚠️ 6 Missing
upgrade.ts 93.83% ⚠️ 5 Missing
resolver.ts 94.57% ⚠️ 5 Missing
env-file.ts 97.58% ⚠️ 3 Missing
project-aliases.ts 97.40% ⚠️ 2 Missing
project-root-cache.ts 96.92% ⚠️ 2 Missing
alias.ts 99.28% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
colors.ts 97.96% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    77.35%    77.20%    -0.15%
==========================================
  Files           55        57        +2
  Lines         7394      7497      +103
  Branches         0         0         —
==========================================
+ Hits          5719      5788       +69
- Misses        1675      1709       +34
- Partials         0         0         —

Generated by Codecov Action

@BYK
BYK merged commit 7717b3f into main Feb 5, 2026
24 checks passed
@BYK
BYK deleted the byk/test-resolve-target branch February 5, 2026 16:54
betegon added a commit that referenced this pull request Jul 15, 2026
## Summary

Extends the Sentry Init Mastra API timeout from 180 seconds to 210
seconds.

A recent Next.js run completed the server-side Plan code changes step in
192.97 seconds, but the CLI crossed its 180-second deadline before the
result arrived. The additional 30 seconds covers that observed case
while the underlying Docs MCP latency is tracked separately in
getsentry/cli-init-api#199.

The recovery test now proves the exact boundary: recovery has not
started at 209,999 ms and starts after the final millisecond.

## Test plan

- `pnpm exec vitest run test/lib/init/wizard-runner.test.ts` — 56 tests
pass
- `pnpm run lint` — 917 files pass
- `pnpm run generate:schema && pnpm run typecheck` — passes
- `git diff --check` — passes
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant